Fixed SKGLView on Android not being rendered when using a TabBar #3076
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Currently an
SKGLView
on Android will not render when it appears for a second time, such as when theSKGLView
is placed on a MAUI Tab Page in a TabBar. The first time the Tab with theSKGLView
is displayed it correctly renders, however when switching to a different Tab and then coming back, theSKGLView
will not render anymore.This PR solves this issue by constructing the internal
GLThread
with the current size of the View, instead of relying on Android to callGLTextureView.OnLayoutChange()
. If the size of the View has not been set yet by Android (which happens when theSKGLView
is displayed for the first time), the GLTextureView's Width and Height are both 0, just as the default of the GLThread used to be, so it is safe to use these values when constructing theGLThread
.Bugs Fixed
API Changes
No public API changes.
Private API Change:
SkiaSharp.Views.Android.GLTextureView.GLThread(WeakReference<GLTextureView> glTextureViewWeakRef)
=>GLThread(WeakReference<GLTextureView> glTextureViewWeakRef, int initialWidth, int initialHeight)
Behavioral Changes
None.
Required skia PR
None.
PR Checklist